<template>
  <div class="page" id="app">
    <el-container style="height: 100%;min-height:100vh;">
      <el-aside width="200px" style="background-color:#666;">
        <el-menu
          :default-active="defaultIndex"
          background-color="#666"
          text-color="#fff"
          active-text-color="#fff"
          @select="selectMenu"
        >
          <el-menu-item >
            <span>智行合创厂商版</span>
          </el-menu-item>
          <el-menu-item index="/index" route="/index">
            <i class="el-icon-s-home"></i>
            <span slot="title">主页</span>
          </el-menu-item>
          <el-menu-item index="/client" route="/client">
            <i class="el-icon-s-custom"></i>
            <span slot="title">客户</span>
          </el-menu-item>
          <el-menu-item index="/device" route="/device">
            <i class="el-icon-s-platform"></i>
            <span slot="title">设备</span>
          </el-menu-item>
          <el-submenu index="3">
            <template slot="title">
              <i class="iconfont">&#xe738;</i>
              <span>盈利</span>
            </template>
            <el-menu-item-group>
              <el-menu-item  index="/withdraw" route="/withdraw">提现中心</el-menu-item>
              <el-menu-item index="/recording" route="/recording">交易记录</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-s-data"></i>
              <span>报告</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/analysis" route="/analysis">数据分析</el-menu-item>
              <el-menu-item index="/point" route="/point">机器布点</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
        <div class="sett">
          <i class="el-icon-s-tools"></i>
          设置
        </div>
      </el-aside>

      <el-container>
        <el-header style="text-align: right; font-size: 16px ;  line-height: 60px;">
          <el-dropdown>
            <i class="iconfont" style="margin-right: 15px">&#xe62d;</i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <span>您好！王小虎</span>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style lang="less">
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  // text-align: center;
  color: #000;
}
#nav {
  padding: 30px;
  a {
    font-weight: bold;
    color: #2c3e50;
    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
<script>
export default {
  name: "home",
  props: {},
  data() {
    const item = {
      date: "2016-05-02",
      name: "王小虎",
      address: "上海市普陀区金沙江路 1518 弄"
    };
    return {
      tableData: Array(20).fill(item)
    };
  },
  computed: {
    defaultIndex: {
      get() {
        console.log(this.$route.path);
        let indexMenu =
          this.$route.path == "/index" || this.$route.path == "/" ? "/index" : this.$route.path;
        return indexMenu;
      },
      set(val) {
        console.log(val)
        return val;
      }
    }
  },
  created() {},
  mounted() {},
  watch: {
    // $route(to, from) {
    //   console.log(to.path);
    //   if (to.path == "/index") {
    //     this.defaultIndex = "1";
    //   } else if (to.path == "/client") {
    //     this.defaultIndex = "2";
    //   }
    // }
  },
  methods: {
    selectMenu(key, keyPath) {
      console.log(key);
        this.$router.push(key);

        // this.$router.push("/client");
      
    }
  },
  components: {}
};
</script>

<style scoped lang="less">
.sett {
  position: fixed;
  left: 50px;
  bottom: 20px;
  color: #fff;
  z-index: 10;
  cursor: pointer;
}
</style>
<style>
.page /deep/ .el-menu-item.is-active {
  background-color: #ff7d31 !important;
}
.is-opened {
  background: #1b1b1b !important;
}
</style>
